package net.pm.core.service.pmuser;

import java.util.List;

import net.pm.common.service.GenericServicer;
import net.pm.common.toolkit.PMRetcodeGenerator;
import net.pm.common.toolkit.PMRetcodeWrapper;
import net.pm.common.toolkit.Pager;
import net.pm.core.entities.db.Pmuser;

public interface PMUserServicer extends GenericServicer<Pmuser, Long>{
	
	/**
	 * 用户登录处理
	 * @param loginname
	 * @param passwd
	 * @param kaptchacode
	 * @return
	 */
	PMRetcodeWrapper<Pmuser> login(String loginname,String passwd);
	Long login_success = PMRetcodeGenerator.next();						//登录成功
	Long login_failed_loginname_notexists = PMRetcodeGenerator.next();	//用户名不存在
	Long login_failed_passwd_error = PMRetcodeGenerator.next();			//密码错误
	Long login_failed_account_disable = PMRetcodeGenerator.next();		//帐户被禁用
	
	
	
	/**
	 * 更新密码
	 * @param newpasswd
	 * @param userid
	 */
	void modifyPasswd(String newpasswd, Long userid);
	
	/**
	 * 查找当前用户所在部门的所有的用户
	 * @param pagersize
	 * @param pageno
	 * @return
	 */
	Pager<Pmuser> findUserPagerByOwner(Integer deptId,Integer pagesize,Integer pageno);
	
	/**
	 * 激活当前用户
	 * @param userId
	 */
	Long enableUser(Long userId);
	Long enable_user_success = PMRetcodeGenerator.next();		//启用用户成功
	Long enable_user_failed = PMRetcodeGenerator.next();		//启用用户失败
	
	/**
	 * 禁用当前用户
	 * @param userId
	 */
	Long disableUser(Long userId);
	Long disable_user_success = PMRetcodeGenerator.next();		//禁用用户成功
	Long disable_user_failed = PMRetcodeGenerator.next();		//禁用用户失败
	
	
	/**
	 * 重置用户密码
	 * @param passwd
	 * @param userId
	 */
	Long resetPasswd(String passwd,Long userId);
	Long reset_passwd_success = PMRetcodeGenerator.next();		//重置密码成功
	Long reset_passwd_failed = PMRetcodeGenerator.next();		//重置密码失败
	/**
	 * 更新用户信息
	 * @param pmuser
	 */
	void modifyUserInfo(Pmuser pmuser);
	
	/**
	 * 创建一个新用户
	 * @param user
	 * @return
	 */
	Long createUser(Pmuser user);
	Long create_user_success = PMRetcodeGenerator.next();	//创建新用户成功
	Long create_user_failed = PMRetcodeGenerator.next();	//创建新用户失败
	
	/**
	 * 根据部门id查找用户列表
	 * @param deptId
	 * @return
	 */
	List<Pmuser> findUsersByDeptId(Integer deptId);

	/**
	 * 用户注册
	 * @param loginname
	 * @param passwd
	 * @return
	 */
	PMRetcodeWrapper<Pmuser> register(String loginname, String passwd);
	
}